import json

with open(r'c:\tools\sw_templates.json') as f:
	templates=json.load(f)

print(type(templates))
print(templates)

for section,commands in templates.items():
	print(section)
	print('\n'.join(commands))


with open(r'c:\tools\sw_templates.json') as f:
	file_content=f.read()
	templates=json.loads(file_content)

print(type(templates))
print(templates)

for section,commands in templates.items():
	print(section)
	print('\n'.join(commands))


access_template=[
	'port link-type access','port default vlan 110'
]

trunk_template=[
	'port priority 5','port link-type trunk'
]

to_json={'trunk':trunk_template,'access':access_template}

print(type(to_json))
print(to_json)


with open('sw_templates_dump.json','w') as f:
	json.dump(to_json,f)


with open('sw_templates_dump1.json','w') as f:
	f.write(json.dumps(to_json))


with open('sw_templates_dump2.json','w') as f:
	json.dump(to_json,f,sort_keys=True,indent=2)
